package controllers

import (
	"fs_oms/models"
	"github.com/astaxie/beego"
)

type DelSubController struct {
	beego.Controller
}

func (c *DelSubController) Get() {
	c.TplName = "delsub.tpl"
}

func (c *DelSubController) Post() {
	var accountcode = c.GetString("accountcode")
	if !models.IsSubscriberExist(accountcode) {
		c.Data["result"] = "用户" + accountcode + "不存在!"
	} else {
		err := models.DelSubscriber(accountcode)
		if err != nil {
			c.Data["result"] = "删除用户" + accountcode + "失败!"
		} else {
			models.SyncData()
			c.Data["result"] = "删除用户" + accountcode + "成功!"
		}
	}

	c.TplName = "delsub_result.tpl"
}
